<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>偶数奇数和</title>
    <style>
        a{
            color: #c01900;
            text-decoration: none;
        }
    </style>
</head>
<body>
<a href="打印出直角三角形.html">打印出直角三角形</a>
<br/>
<br/>
<script>


    var sum = 0;
    for (i = 1; i < 101; i++) {
// sum += i;
        sum = sum + i;
    }

    document.write(sum + "<br/>");


    document.write("<br/>");
    document.write("<br/>");


    var oddsum = 0;  // 奇数和
    var evensum = 0;// 偶数和
    for (var i = 0; i <= 100; i++) {
        if (i % 2 == 0) {
            oddsum += i;
        } else {
            evensum += i;
        }
        sum += i;
    }
    document.write("100以内的奇数和：" + oddsum + "<br/>");
    document.write("100以内的偶数和：" + evensum + "<br/>");
</script>
</body>
</html>